import http from "../index";

// 分页获取充值优惠
export const getDiscounts = ({
    ascended = null,
    current = null,
    size = null,
    sortFieldName = null,
    status = null,
    couponName = null,
    sendOut = null,
}) => {
    return http.get("recharge-discounts", {
        ascended,
        current,
        size,
        sortFieldName,
        status,
        couponName,
        sendOut,
    });
};

// 根据sid获取充值优惠
export const getDiscountDetail = ({ sid }) => {
    return http.get("recharge-discounts/" + sid);
};

// 新增充值优惠
export const addDiscount = ({
    couponName,
    couponType,
    limitation,
    minAmount,
    expireTime = null,
    note = null,
    number = null,
    preferential = null,
    ratio = null,
    status = null,
}) => {
    return http.post("recharge-discounts", {
        couponName,
        couponType,
        limitation,
        minAmount,
        expireTime,
        note,
        number,
        preferential,
        ratio,
        status,
    });
};

// 修改充值优惠
export const editDiscount = ({
    sid,
    couponName,
    couponType,
    limitation,
    minAmount,
    expireTime = null,
    note = null,
    number = null,
    preferential = null,
    ratio = null,
    status = null,
}) => {
    return http.put("recharge-discounts/" + sid, {
        couponName,
        couponType,
        limitation,
        minAmount,
        expireTime,
        note,
        number,
        preferential,
        ratio,
        status,
    });
};

// 批量删除充值优惠
export const delDiscounts = ({ sidList }) => {
    return http.put("recharge-discounts/delete", { sidList });
};

// 根据sid发放充值优惠
export const grantDiscount = ({ sid }) => {
    return http.put("recharge-discounts/" + sid + "/grant");
};

// 根据sid启用-停用充值优惠
export const changeDiscountStatus = ({ sid }) => {
    return http.put("recharge-discounts/" + sid + "/status");
};
